<?php


namespace app\user\controller;


use app\common\controller\Api;
use app\user\model\DetailModel;

class Detail extends Base
{
    protected $noNeedLogin = '*';

    public function index1()
    {
        $date = DetailModel::order('id','DESC')
            ->field('id,image,name,profilee,sales,money,deposit')
            ->select();
        if (!$date) {
            $this->error('错误');
        }
        $this->success('查询成功',[
            'list' => $date
        ]);
    }

    public function list()
    {
        $menuId = input('menuId/d');


        if (empty($menuId)){
            $this->error('分类ID不能为空');
        }

        $list = DetailModel::where('procate',$menuId)
            ->order('sales DESC,money DESC')
            ->field('id,image,profilee,sales,money,deposit')
            ->select();
        if (!$list){
            $this->error('不存在');
        }
        $this->success('查询成功',[
            'list' => $list
        ]);
    }

    public function detail()
    {
        $id = input('id/d');
        if (empty($id)){
            $this->error('ID不能为空');
        }
        $date = DetailModel::field('id,images,name,profilee,rulecontent,sales,money,deposit')->find($id);
        if (!$date) {
            $this->error('不存在');
        }
        $this->success('查询成功',[
            'detail' => $date
        ]);

    }

}